Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gen docs in js actions #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

porfirioribeiro
Copy link

Generate the same docs for redux actions as we have in plain openapi call's

Usefull for code completition of actions

@@ -268,6 +268,7 @@ function renderTypeDoc(name: string, def: any): string[] {
if (propLines.length) lines.push(`${DOC}`)
join(lines, propLines)
lines.push(' */')
lines.push(`const ${name}=null`)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify this one? It's not need to add code in my testing. Also setting to null causes issues for people not allowing null's in their code base.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really needed. For what i see the Types.js file is not really used anywhere.
It does not contain any code
It's there just to give code completion.
My problem was that some CodeEditor's would not find the @typedef and won't give code completion as they assume that typedef is not defined.
But this probably a problem to be solved in code editors, not in code gen, thought it does not hurt anyone

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it is removed by code minification, but potentially it can hurt "anyone" because you're potentially shipping more bytes through the wire.

@@ -48,14 +48,17 @@ function renderReduxActionBlock(spec: ApiSpec, op: ApiOperation, options: Client
if (required.length) params += ', options'
else params = 'options'
}

const docsArray=renderOperationDocs(op)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gets you most of the way there, but the promise returned from redux action creators are not the same as the promise returned from the raw service call. This means there's incorrect promise typings being gen'd.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhh yes you are right, didn't tough about that as mostly i only wanted to get completion in action's arguments.

So probably this needs more work, can't just use the same gen docs from the other methods.

@@ -1,6 +1,6 @@
import { writeFileSync, join, groupOperationsByGroupName, camelToUppercase, getBestResponse } from '../util'
import { DOC, SP, ST, getDocType, getTSParamType } from './support'
import { renderParamSignature, renderOperationGroup } from './genOperations'
import {renderParamSignature, renderOperationGroup, renderOperationDocs} from './genOperations'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spacing consistency

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, right. The block was formatted by the code editor on import.
Should have payed more attention before commit and submit the PR

@mikestead
Copy link
Owner

@porfirioribeiro thanks for the pull request. Left a few comments.

@porfirioribeiro
Copy link
Author

@mikestead I will look at all your comments and try to fix all.
I am not very pro in making contributions yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants